package com.dragon.refect.error;

import net.sf.cglib.proxy.Enhancer;
import net.sf.cglib.proxy.MethodInterceptor;

/**
 * -XX:MaxMetaspaceSize=10M
 * 设置最大的元空间的存储空间大小
 *
 * @author dragon
 * @since 2019/12/12
 */
public class JavaMethodAreaOOM {

    public static void main(String[] args) {
        for (; ; ) {
            Enhancer enhancer = new Enhancer();
            enhancer.setSuperclass(JavaMethodAreaOOM.class);
            enhancer.setUseCache(false);
            enhancer.setCallback((MethodInterceptor) ((obj, method, argument, proxy) -> proxy.invokeSuper(obj,
                    argument)));
            enhancer.create();
        }
    }
}
